
#定义一个存放银行客户信息的变量
clientinfo=[{"Name":"Jack","a/c no.":"1234567890","Password":"111111","Balance":"10000"},
			{"Name":"Rose","a/c no.":"2234567890","Password":"222222","Balance":"8000"},
			{"Name":"Nick","a/c no.":"3234567890","Password":"333333","Balance":"5000"}]


while True:
	#输入账号并判断账号是否在已有账号中
	print("=============Welcome to Fortune Bank!=============")
	print("(Enter \"quit\" to quit)")
	keyac=input("please enter account number:")
	if keyac=="quit":
		break
	else:
		#遍历出所有的账号信息并形成账号列表
		aclist=[]
		for i in clientinfo:
			aclist.append(i["a/c no."])
			
		#判断输入的账号是否在当前的账号信息中

		if keyac in aclist:
			#判断输入的密码是否与账号匹配
			keypw=input("please enter password:")
			c=aclist.index(keyac)
			a=clientinfo[c]
			if keyac==a["a/c no."] and keypw==a["Password"]:
				#登陆后的操作主界面
				while True:
					print ("===============Welcome to Fortune Bank user {}===============".format(i["Name"]))
					print ("{0:26}{1:10}{2:26}".format("","1.Check Balance",""))
					print ("{0:26}{1:10}{2:26}".format("","2.Deposit",""))
					print ("{0:26}{1:10}{2:26}".format("","3.Withdraw",""))
					print ("{0:26}{1:10}{2:26}".format("","4.Change Password",""))
					print ("{0:26}{1:10}{2:26}".format("","5.Quit",""))
					key=input("Please enter a number to select:")
					#查询余额功能
					if key=="1":
						print("Current account balance:",a["Balance"])
						input("Please press enter to continue!")
					#存款功能
					elif key=="2":
						print("Balance:",a["Balance"])
						keydep=input("Enter deposit amount:")
						a["Balance"]=int(a["Balance"])+int(keydep)
						print("New balance:",a["Balance"])
						input("please press enter to continue!")
					#取款功能
					elif key=="3":
						print("Balance:",a["Balance"])
						keydraw=input("Enter withdrawal amount:")
						if int(keydraw)<=int(a["Balance"]):
							a["Balance"]=int(a["Balance"])-int(keydraw)
							print("New balance:",a["Balance"])
							input("please press enter to continue!")
						else:
							print("Inadquate balance!")
							input("please press enter to continue")
					#修改密码功能
					elif key=="4":
						print("Current Password:",a["Password"])
						keydep=input("Enter new password:")
						a["Password"]=keydep
						print("New password:",a["Password"])
						input("please press enter to continue!")
					#退出
					elif key=="5":
						print("==================See you next time!====================")
						break
					else:
						print("Invalid input, pleas enter your selection again!")



			elif keyac!=a["a/c no."] or keypw!=a["Password"]:
				print("Password and account number doesnot match, please log in again!")
		else:
			print("account does not exist")







